<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['education']) && ($_SESSION['education'] <= 0))) {
	$this->_redirect(HOST_BACKEND);
}
$intStatus		= $objRequest->getParam('stt', -1);
$intOption		= $objRequest->getParam('opt', 0);
$strKey			= $objRequest->getParam('key', '');
$strStart		= $objRequest->getParam('startdate', '');
$strEnd			= $objRequest->getParam('enddate', '');
$intCategoryId	= $objRequest->getParam('cate', 0);
$intProvince	= $objRequest->getParam('prov', 0);
$intDistrict	= $objRequest->getParam('dist', 0);
$intPage		= $objRequest->getParam('page', 1);
$intCancel		= $objRequest->getParam('pcancel', 0);
$intLimit		= $variable['ADMIN_LIMIT']['val'];
$intOff			= (($intPage-1) * $intLimit);
$intTotal		= 0;
$intType		= 0;
if($intCancel) {
	$intLanguage	= 0;
	$intOption		= 0;
	$intCategoryId	= 0;
	$intProvince	= 0;
	$intDistrict	= 0;
	if(isset($_SESSION['EDUCATION_POST'])) unset($_SESSION['EDUCATION_POST']);
	if(isset($_SESSION['EDUCATION_CANCEL'])) unset($_SESSION['EDUCATION_CANCEL']);
	unset($strKey);
	unset($strStart);
	unset($strEnd);
}

$objEducation	= new Education(); 
$objCommon		= new Ecore_Common();

$arrResult		= $objEducation->getAll($AppUI->type, $intCategoryId, $intType, $intStatus, $intOption, 
										$strKey, Ecore_Function::convertStrToDate($strStart), Ecore_Function::convertStrToDate($strEnd), $intOff, $intLimit, 
										$intProvince, $intDistrict, $intTotal);
if($intOption != 0 || $strKey != '' || $strStart != '' || $strEnd != '' || $intCategoryId != 0 || $intProvince != 0 || $intDistrict != 0) {
	$_SESSION['EDUCATION_CANCEL'] 	= 1;	
	$_SESSION['EDUCATION_POST']		= $objRequest->getParams();
}
else {
	if(isset($_SESSION['EDUCATION_POST'])) unset($_SESSION['EDUCATION_POST']);
	if(isset($_SESSION['EDUCATION_CANCEL'])) unset($_SESSION['EDUCATION_CANCEL']);
}
# list
$this->view->arrResult		= $arrResult;
$this->view->intTotal		= $intTotal;
$this->view->intOffset		= $intOff;
$this->view->intLimit		= $intLimit;
$this->view->arrOption		= $arrOption;
$this->view->strUrl			= Ecore_Function::getUrl(HOST_BACKEND);
$this->view->arrStatus		= ($AppUI->type == ROOT_ROLE) ? $arrStatusAd : $arrStatus;
$this->view->intLanguage	= $intLanguage;
$this->view->intStatus		= $intStatus;
$this->view->arrProvince	= $objCommon->getProvince();
if($intProvince > 0) {
	$this->view->arrDistrict	= $objCommon->getDistrict($intProvince);
}